export default class Render {
    str='';
    item;
    constructor(select) 
    {
        this.box = document.getElementById(select);
   
        this.pfetch();
        
    }

    async pfetch(start,end) {

        fetch("http://localhost:4022/prolist").then(res => res.json())
            .then(res => {
                this.item=res;
                // console.log(this.item);
                this.render(this.item,start,end);
            })
          
            // console.log(this.item);
    }
    render(res,start,end){
        for(var i=start;i<=end;i++){
            this.str+=`<li data-id="${res[i].proID}" class="lis">
						<a href="./details.html#id=${res[i].proID}" data-id="${res[i].proID}">
                        <img src="${res[i].src}" data-id="${res[i].proID}">
							<h3 class="layui-elip" data-id="${res[i].proID}">
								<img src="https://www.ziyimall.com/file_img/activity/twelve/icon-12.png?n=3" data-id="${res[i].proID}" />
								<span class="layui-elip" id="title" data-id="${res[i].proID}">${res[i].title}</span>
							</h3>
							<div class="other">
								<p>
									<strong><em>￥</em>${res[i].price}</strong>
									<span style="margin: 0;">￥${res[i].no_price}</span>
								</p>
                                </div>
                                </a>
                                </li>`
                            }
                            this.box.innerHTML=this.str;
                        }


}
